import { reactive, toRefs } from 'vue';

const ACTIVITY_ID = 'activityId';

const ACTIVITY_TYPE = 'activityType';

const BUTTON_TYPE = 'buttonType';

const BANNER_SHOW = 'bannerShow';

export default getDetails;

export function getDetails() {
  const state = reactive({
    details: null,
    id: null,
  });

  const setParams = async (id) => {
    // state.id = (await !id) ? getActivityId() : id;
    // setActivityId(state.id);
    // const result = await api.config
    //   .init(state.id)
    //   .then((res) => res)
    //   .catch((error) => {
    //     console.log(error);
    //   });
    // state.details = result;
  };

  const setActivityId = (id) => {
    sessionStorage.setItem(ACTIVITY_ID, id);
  };

  const getActivityId = () => {
    return sessionStorage.getItem(ACTIVITY_ID);
  };

  const setActivityType = (id) => {
    sessionStorage.setItem(ACTIVITY_TYPE, id);
  };

  const getActivityType = () => {
    return sessionStorage.getItem(ACTIVITY_TYPE);
  };

  const setBtnType = (string) => {
    sessionStorage.setItem(BUTTON_TYPE, string);
  };

  const getBtnType = () => {
    return sessionStorage.getItem(BUTTON_TYPE);
  };

  const setBannerShow = (num) => {
    sessionStorage.setItem(BANNER_SHOW, num);
  };

  const getBannerShow = () => {
    return sessionStorage.getItem(BANNER_SHOW);
  };

  return {
    ...toRefs(state),
    setParams,
    getActivityId,
    setActivityType,
    getActivityType,
    setBtnType,
    getBtnType,
    setBannerShow,
    getBannerShow,
  };
}
